package com.boss.salary.workflow.controller;


import com.boss.api.dto.ApiResultDTO;
import com.boss.common.base.BasicinfoBaseController;
import com.boss.common.entity.WfActionDTO;
import com.boss.salary.workflow.service.ISalaryWorkFlowService;
import com.boss.sys.ca.user.dto.UserDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;

/**
 * 工作流统一接口类
 */
@RestController
@RequestMapping(value = "/salaryWorkFlowController", produces = MediaType.APPLICATION_JSON)
public class SalaryWorkFlowController extends BasicinfoBaseController {
    /**
     * 引入日志框架常量
     */
    private final static Logger logger = LoggerFactory.getLogger(SalaryWorkFlowController.class);

    @Autowired
    private ISalaryWorkFlowService iSalaryWorkFlowService;


    /**
     * 单位审核获取说明
     * @param tokenid
     * @param agencyId
     * @return
     */
    @GetMapping("/getAuditInstruction")
    public ApiResultDTO getAuditInstruction( @RequestHeader("X-Token") String tokenid,
                                             @RequestParam(value = "agencyId") String agencyId){
        try {
            UserDTO userDto = getUser(tokenid);
            WfActionDTO wfActionDTO =new WfActionDTO();
            List<Map> auditInstruction = iSalaryWorkFlowService.getAuditInstruction(userDto, wfActionDTO, agencyId);
            return ApiResultDTO.success(auditInstruction);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return ApiResultDTO.error(ERROR_RSCODE, "查询异常");
        }
    }

}
